﻿<Window x:Class="ServeAnything.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:serveAnything="clr-namespace:ServeAnything"
        mc:Ignorable="d"
        Title="Serve Anything" Height="350" Width="525" d:DataContext="{d:DesignInstance serveAnything:ViewModel}"
        Icon="serveanything.ico">
    <Window.Resources>
        <Style x:Key="UserModeTextBoxStyle" TargetType="TextBox">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RunAsSystem}" Value="True">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="UserModeTextBlockStyle" TargetType="TextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RunAsSystem}" Value="True">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Text="Path" Margin="6,6,6,0"/>
        <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path}" Margin="6,6,6,0"/>

        <Button Name="OpenButton" Grid.Row="0" Grid.Column="2" Margin="0,6,6,0" Content="..." 
                Width="24" Height="18" VerticalAlignment="Stretch" Click="OpenButton_OnClick"/>

        <TextBlock Grid.Row="1" Grid.Column="0" Text="Arguments" Margin="6,6,6,0"/>
        <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Arguments}" Margin="6,6,6,0"/>

        <TextBlock Text="Service Name" Margin="6,6,6,0" Grid.Row="2" Grid.Column="0" />
        <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding ServiceName}" Margin="6,6,6,0"/>

        <CheckBox Name="RunAsSystemCheckBox" Grid.Row="3" Grid.Column="1" Margin="6" Content="Run as system" IsChecked="{Binding RunAsSystem}"/>

        <TextBlock Grid.Row="4" Grid.Column="1" Margin="6" Text="Please specify the account the service should run under.  This account must have access to the specified path as well as the current user directory.  It is highly recommended that this account be the current (executing) account."
                   Style="{StaticResource UserModeTextBlockStyle}"  TextWrapping="Wrap"/>

        <TextBlock Text="Username" Margin="6,6,6,0" Grid.Row="5" Grid.Column="0" Style="{StaticResource UserModeTextBlockStyle}"/>
        <TextBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Username}" Margin="6,6,6,0"
                 Style="{StaticResource UserModeTextBoxStyle}"/>

        <TextBlock Text="Password" Margin="6,6,6,0" Grid.Row="6" Grid.Column="0" Style="{StaticResource UserModeTextBlockStyle}"/>
        <TextBox Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Password}" Margin="6,6,6,0"
                 Style="{StaticResource UserModeTextBoxStyle}"/>

        <StackPanel  Grid.Row="7" Grid.ColumnSpan="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal">

            <TextBlock Margin="6" Text="{Binding Status}" VerticalAlignment="Center"/>

            <Button Name="InstallButton" Margin="6" Padding="6"
                Content="Install" Click="installButton_Click"/>

            <Button Name="UninstallButton" HorizontalAlignment="Right" Margin="0,6,6,6" Padding="6"
                Content="Uninstall" Click="UninstallButton_Click"/>
        </StackPanel>
    </Grid>
</Window>
